package com.example.parsing.unit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class ReadAndWrite {
	
	private static final Logger logger = LoggerFactory.getLogger(ReadAndWrite.class);
	
	
	public static void writeTxtJson(File file){
		try{
			BufferedWriter bw = new BufferedWriter(new FileWriter("readTxtJson.txt",true));
			bw.write(file.getName());
			bw.newLine();
			bw.flush();
			bw.close();
		}catch (Exception e){
			logger.error("写入已经读的txt的Json文本出错");
		}
	}
	
	public static List<String> readTxtJson(){
		List<String> list = new ArrayList<>();
		try{
			BufferedReader br = new BufferedReader(new FileReader("readTxtJson.txt"));
			String s;
			while ((s = br.readLine())!=null){
				list.add(s);
			}
			return list;
		}catch (Exception e){
			logger.error("读取已经操作过的txt的Json文本");
		}
		return list;
	}
}
